
using Abp.Domain.Repositories;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


namespace SOEI.Solution.DomainEntities.RoomSourceVerifiyV1.DomainService
{
    /// <summary>
    /// 领域服务层一个模块的核心业务逻辑
    ///</summary>
    public class LicensesUploadManager : DomainServiceBase, ILicensesUploadManager
    {

        private readonly IRepository<LicensesUpload, string> _licensesuploadRepository;

        /// <summary>
        /// 【LicensesUpload】的构造方法
        /// 通过构造函数注册服务到依赖注入容器中
        ///</summary>
        public LicensesUploadManager(IRepository<LicensesUpload, string> licensesuploadRepository)
        {
            _licensesuploadRepository = licensesuploadRepository;
        }

        #region -------------------------------------------------辅助工具生成---------------------------------------------- 

        /// <summary>
        /// 返回列表查询用
        /// </summary>
        /// <returns></returns>
        public IQueryable<LicensesUpload> QueryEntityListAsNoTracking()
        {

            var query = _licensesuploadRepository.GetAll().AsNoTracking()
                        .Select(x => new LicensesUpload
                        {

                            Id = x.Id,
                            XM = x.XM,
                            ZJLX = x.ZJLX,
                            ZJHM = x.ZJHM,
                            LXDH = x.LXDH,
                            TXDZ = x.TXDZ,
                            SFLBDM = x.SFLBDM,
                            WTHTBH = x.WTHTBH,
                            ZJLXDM = x.ZJLXDM,
                            GZDW = x.GZDW,
                            YB = x.YB,
                            FBBH = x.FBBH,
                        });
            return query;
        }

        /// <summary>
        /// 【LicensesUpload】返回表达式数的实体信息即IQueryable类型
        /// </summary>
        /// <returns>IQueryable</returns>
        public IQueryable<LicensesUpload> Query()
        {
            return _licensesuploadRepository.GetAll();
        }
        /// <summary>
        /// 【LicensesUpload】返回即IQueryable类型的实体，不包含EF Core跟踪标记
        /// </summary>
        /// <returns>IQueryable</returns>
        public IQueryable<LicensesUpload> QueryAsNoTracking()
        {
            return _licensesuploadRepository.GetAll().AsNoTracking();
        }
        /// <summary>
        /// 【LicensesUpload】根据Id查询实体信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns>实体</returns>
        public async Task<LicensesUpload> FindByIdAsync(string id)
        {
            var entity = await _licensesuploadRepository.GetAsync(id);
            return entity;
        }
        /// <summary>
        /// 【LicensesUpload】检查实体是否存在
        /// </summary>
        /// <param name="id"></param>
        /// <returns>bool</returns>
        public async Task<bool> IsExistAsync(string id)
        {
            var result = await _licensesuploadRepository.GetAll().AnyAsync(a => a.Id == id);
            return result;
        }
        /// <summary>
        /// 【LicensesUpload】创建实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<LicensesUpload> CreateAsync(LicensesUpload entity)
        {
            entity.Id = await _licensesuploadRepository.InsertAndGetIdAsync(entity);
            return entity;
        }
        /// <summary>
        /// 【LicensesUpload】更新实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task UpdateAsync(LicensesUpload entity)
        {
            await _licensesuploadRepository.UpdateAsync(entity);
        }
        /// <summary>
        /// 【LicensesUpload】删除实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task DeleteAsync(string id)
        {
            //TODO:删除前的逻辑判断，是否允许删除
            await _licensesuploadRepository.DeleteAsync(id);
        }
        /// <summary>
        /// 【LicensesUpload】批量删除
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task BatchDelete(List<string> input)
        {
            //TODO:删除前的逻辑判断，是否允许删除
            await _licensesuploadRepository.DeleteAsync(a => input.Contains(a.Id));
        }
        #endregion


        #region -------------------------------------------------用户自定义------------------------------------------------
        /*请在此扩展领域服务接口*/
        #endregion









    }
}
